<template>
  <div class="login-container">
    <div class="login-form-wrap">
      <div class="login-head">
        <div class="logo"></div>
      </div>
      <el-form class="login-form" ref="form" :model="user" size="medium">
        <!-- el-form：表单组件，每个表单项必须使用 el-form-item 组件包裹-->
        <el-form-item>
          <el-input v-model="user.mobile" placeholder="请输入手机号" autofocus=true></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="user.code" placeholder="请输入验证码"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="login-btn" type="primary" @click="onLogin">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import request from '@/util/request'

export default {
  name: 'LoginIndex',
  components: {},
  props: {},
  data () {
    return {
      user: {
        mobile: '', // 手机号
        code: '' // 验证码
      }
    }
  },
  computed: {},
  watch: {},
  created () {
  },
  mounted () {
  },
  methods: {
    onLogin () {
      // 获取表单数据（根据接口要求绑定数据）
      const user = this.user
      request({
        method: 'POST',
        url: '/login',
        data: user
      })
      // 表单验证
      // 验证通过，提交登录
      // 处理登录响应结果
      console.log(user)
    }
  }
}
</script>

<style scoped lang="less">
  .login-container {
    /*固定定位*/
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    // 水平居中
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* 垂直居中 */
    align-items: center;
    // background: url('./最.png') no-repeat;
    /*background-color: #9B59B6;*/
    /*background-size: cover;*/
    /*登录表单 CSS 设置*/
    .login-form-wrap {
      background-color: #9B59B6;
      min-width: 300px;
      padding: 10px 50px 15px;
      .login-head {
        height: 30px;
        display: flex;
        justify-content: center;
        .logo {
          width: 30px;
          height: 30px;
          /*background: url('./最.png') no-repeat;*/
          background-size: contain;
        }
      }
      .login-form {
        .login-btn {
          width: 100%;
        }
      }
    }
  }
</style>
